<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    标题：<input type="text" id="title"><br/>
    内容：<input type="text" id="content"><br/>
    <input type="button" id="fabiao" value="发表">
</form>
</body>
</html>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('#fabiao').click(function () {
            fabiao();
        })
    })

    function fabiao (){
        var title = $('#title').val();
        var content = $('#content').val();
        $.ajax({
            "url":"/T309tgspringboot/post/insertPsst",
            "type":"get",
            "data":{
                "title":title,
                "content":content
            },
            "dataType":"json",
            "success":function(a){
                var r = parseInt(a.result["num"]);
                if(r>0){
                    window.location.href="/T309tgspringboot/community";
                }else{
                    alert("发表失败");
                    window.location.href="/T309tgspringboot/fabiaotiezi";
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    }
</script>